<template>
  <el-dialog
    title="新增轮播"
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    :destroy-on-close="true"
    width="700px"
    :close-on-click-modal="false">
    <el-form
      :model="form"
      :rules="rule"
      ref="form"
      style="width: 100%"
      label-width="100px"
    >
      <el-form-item label="图片：" prop="second">
        <el-image
          style="width: 100px; height: 100px"
          src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
          ></el-image>
        <p class="image-info">建议尺寸大小：658*259</p>
      </el-form-item>
      <el-form-item label="跳转页面：" prop="url">
        <el-select v-model="form.url" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态：" prop="status">
        <el-radio-group v-model="form.status">
          <el-radio :label="1">显示</el-radio>
          <el-radio :label="2">隐藏</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <div slot="footer" style="display: flex;justify-content: center;">
      <el-button type="primary"
                 @click="cancel"
                 native-type="submit">取消
      </el-button>
      <el-button type="primary"
                 native-type="submit">保存
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'banner-edit',
  data () {
    return {
      dialogVisible: false,
      form: {
        image: '',
        url: '',
        status: 1
      },
      options: [
        {
          label: '充值',
          value: '1'
        }, {
          label: '提现',
          value: '2'
        }, {
          label: '排行榜',
          value: '3'
        }, {
          label: '新人任务',
          value: '4'
        }, {
          label: '每日任务',
          value: '5'
        }, {
          label: '任务大厅',
          value: '6'
        }, {
          label: '邀请好友',
          value: '7'
        }, {
          label: '发布任务',
          value: '8'
        }, {
          label: '发单规则',
          value: '9'
        }, {
          label: '接单规则',
          value: '10'
        }, {
          label: '联系客服',
          value: '11'
        }, {
          label: '帮助中心',
          value: '12'
        }
      ],
      rule: {
        image: [
          { required: true, message: '请选择图片' }
        ]
      }
    }
  },
  methods: {
    handleClose (done) {
      done()
    },
    open () {
      this.dialogVisible = true
      return new Promise((resolve) => {
        this._resolve = resolve
      })
    },
    cancel () {
      this.close()
    },
    close () {
      this.dialogVisible = false
    }
  }
}
</script>

<style scoped lang="scss">
.image-info {
  margin: 0;
}
</style>
